package jnote;

import java.awt.Image;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;

public class About extends JDialog {
    About() {       
        setTitle("About Jnote");
        
        /*
         * This prevent to close the application before closing the about dialog
         */
        setModal(true);
        
        Image im = Toolkit.getDefaultToolkit().getImage("res/notepad_small.png");
        Box b = Box.createVerticalBox();
        b.add(Box.createGlue());
        b.add(new JLabel("Jnote, a text editor written in Java"));
        b.add(new JLabel("Author : Cotugno Vincenzo"));
        b.add(new JLabel("Email : vincenzo dot cotugno dot 89 at gmail dot com"));
        b.add(Box.createGlue());
        getContentPane().add(b, "Center");

        JPanel p2 = new JPanel();
        JButton ok = new JButton("Ok");
        p2.add(ok);
        getContentPane().add(p2, "South");

        ok.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent evt) {
                setVisible(false);
            }
        });
        
        setSize(270, 150);
        setIconImage(im);
        setLocationRelativeTo(null);
        setResizable(false);
        
        try {
            UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
        } catch(UnsupportedLookAndFeelException | ClassNotFoundException |
                InstantiationException | IllegalAccessException e) {
        }
    }
}
